//
//  RBServiceOrderDetailVC.m
//  zhongzhenglu
//
//  Created by XL on 2022/8/15.
//

#import "RBServiceOrderDetailVC.h"
#import "RBDefine.h"
#import "UIView+RBAdd.h"
#import "UIScrollView+RBAdd.h"
#import <Masonry.h>
#import "RBThemeConfig.h"
#import <UIColor+YYAdd.h>
#import <UIView+YYAdd.h>
#import "RBPager.h"
#import <UINavigationController+FDFullscreenPopGesture.h>
#import "RanTool.h"

@interface RBServiceOrderDetailVC ()

@property(nonatomic, strong)UIScrollView *scrollView;

@end

@implementation RBServiceOrderDetailVC

#pragma mark - Lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setup];
    [self fillData];
}

#pragma mark - Private

- (void)setup
{
    self.title = @"售后/退款订单";
    self.view.backgroundColor = [RBThemeConfig bgGrayColor];
}

- (void)fillData
{
    [self.scrollView rbSetContentWidth:kRBMainScreenWidth];
    [self.scrollView addView:({
        UIView *view = UIView.new;
        view.backgroundColor = UIColor.whiteColor;
        [view rbSetCornerRadius:Zoom(8)];
        
        [view view_addView:[self headerViewWithTitle:@"退款成功" time:@"2021年1月3日 19:00" money:@"￥100.00" dotColor:[UIColor colorWithHexString:@"#0ACB00"]] withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:Zoom(33) bottom:Zoom(40) left:0 right:0 centerX:0];
        [view view_addView:[self itemViewWithTitle:@"退回优惠券" money:@"￥10.00"] withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:Zoom(22) bottom:Zoom(40) left:0 right:0 centerX:0];
        [view view_addView:[self itemViewWithTitle:@"退回虚拟币" money:@"20"] withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:Zoom(22) bottom:Zoom(40) left:0 right:0 centerX:0];
        
        [view view_addView:[self headerViewWithTitle:@"退款失败" time:@"2021年1月3日 18:00" money:@"￥100.00" dotColor:[UIColor colorWithHexString:@"#CB0000"]] withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:Zoom(33) bottom:Zoom(40) left:0 right:0 centerX:0];
        [view view_addView:[self itemViewWithTitle:@"7天无理由退款" money:@""] withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:Zoom(22) bottom:Zoom(40) left:0 right:0 centerX:0];
        
        [view view_addView:[self headerViewWithTitle:@"申请退款" time:@"2021年1月3日 17:00" money:@"￥100.00" dotColor:[UIColor colorWithHexString:@"#518CFF"]] withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:Zoom(33) bottom:Zoom(40) left:0 right:0 centerX:0];
        
        view;
    }) withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:Zoom(10) bottom:Zoom(10) left:Zoom(12) right:Zoom(12) centerX:0];
}

#pragma mark - Network

#pragma mark - Event

#pragma mark - Setter

#pragma mark - Getter

- (UIScrollView *)scrollView
{
    if (!_scrollView)
    {
        self.scrollView = ({
            UIScrollView *view = UIScrollView.new;
            [self.view addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.edges.mas_equalTo(0);
            }];
            view;
        });
    }
    return _scrollView;
}

- (UIView *)headerViewWithTitle: (NSString *)title time: (NSString *)time money: (NSString *)money dotColor: (UIColor *)dotColor
{
    UIView *view = UIView.new;
    
    UIView *dotView = UIView.new;
    [dotView rbSetCornerRadius:Zoom(4)];
    dotView.backgroundColor = dotColor;
    [view addSubview:dotView];
    [dotView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(Zoom(16));
        make.width.height.mas_equalTo(Zoom(8));
    }];
    
    UILabel *titleL = [RanTool labelWithFontSize:Zoom(14) weight:1 color:@"222222" align:0 text:title];
    [view addSubview:titleL];
    [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(dotView.mas_right).offset(Zoom(6));
        make.top.mas_equalTo(0);
    }];
    [dotView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(titleL);
    }];
    
    UILabel *timeL = [RanTool labelWithFontSize:Zoom(13) weight:0 color:[RBThemeConfig textGrayColor] align:0 text:time];
    [view addSubview:timeL];
    [timeL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(titleL);
        make.top.mas_equalTo(titleL.mas_bottom).offset(Zoom(9));
        make.bottom.mas_equalTo(0);
    }];
    
    UILabel *moneyL = [RanTool labelWithFontSize:Zoom(13) weight:1 color:[RBThemeConfig priceRedColor] align:0 text:money];
    [moneyL setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh + 1 forAxis:UILayoutConstraintAxisHorizontal];
    [moneyL setContentHuggingPriority:UILayoutPriorityDefaultHigh + 1 forAxis:UILayoutConstraintAxisHorizontal];
    [view addSubview:moneyL];
    [moneyL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(titleL.mas_right).offset(Zoom(12));
        make.right.mas_equalTo(-Zoom(15));
        make.centerY.mas_equalTo(titleL);
    }];
    
    return view;
}

- (UIView *)itemViewWithTitle: (NSString *)title money: (NSString *)money
{
    UIView *view = UIView.new;
    
    UILabel *titleL = [RanTool labelWithFontSize:Zoom(13) weight:1 color:[RBThemeConfig textLightBlackColor] align:0 text:title];
    titleL.numberOfLines = 0;
    [view addSubview:titleL];
    [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(Zoom(31));
        make.top.bottom.mas_equalTo(0);
    }];
    
    UILabel *moneyL = [RanTool labelWithFontSize:Zoom(13) weight:1 color:[RBThemeConfig priceRedColor] align:0 text:money];
    [moneyL setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh + 1 forAxis:UILayoutConstraintAxisHorizontal];
    [moneyL setContentHuggingPriority:UILayoutPriorityDefaultHigh + 1 forAxis:UILayoutConstraintAxisHorizontal];
    [view addSubview:moneyL];
    [moneyL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(titleL.mas_right).offset(Zoom(12));
        make.right.mas_equalTo(-Zoom(15));
        make.centerY.mas_equalTo(titleL);
    }];

    
    return view;
}

@end
